/*
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package me.zhengjie.modules.weChat.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
 * @website https://docs.auauz.net
 * @description /
 * @author 陈震洺
 * @date 2020-05-11
 **/
@Entity
@Data
@Table(name="sys_wechat_user")
public class SysWechatUser implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    private Integer id;

    @Column(name = "user_id")
    @ApiModelProperty(value = "UserId")
    private Long userId;

    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间")
    private Timestamp createTime;

    @ApiModelProperty(value = "open_id")
    private String openId;

    @Column(name = "skey")
    @ApiModelProperty(value = "skey（自定义登录状态）")
    private String skey;

    @Column(name = "last_visit_time")
    @ApiModelProperty(value = "最后登录时间")
    private Timestamp lastVisitTime;

    @Column(name = "session_key")
    @ApiModelProperty(value = "session_key")
    private String sessionKey;

    @Column(name = "city")
    @ApiModelProperty(value = "市")
    private String city;

    @Column(name = "province")
    @ApiModelProperty(value = "省")
    private String province;

    @Column(name = "country")
    @ApiModelProperty(value = "国")
    private String country;

    @Column(name = "avatar_url")
    @ApiModelProperty(value = "头像")
    private String avatarUrl;

    @Column(name = "gender")
    @ApiModelProperty(value = "性别")
    private Integer gender;

    @Column(name = "nick_name")
    @ApiModelProperty(value = "网名")
    private String nickName;

    public void copy(SysWechatUser source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}